# @Author   : 懒羊羊
# @File     : day02_array.py
# @Time     : 2024/11/26 10:23
import copy
import json

# 两值互换
# num1 = 10
# num2 = 25
#
# num1, num2 = num2, num1
#
# print(f"num1:{num1}", f"num2:{num2}", sep="\n")

# 单引号，双引号，三引号
# s1 = '精读需求，编写测试用例（冒烟用例，接口用例，功能测试用例），用例评审会议（铁三角），目的：查漏补缺'
#
# s2 = "精读需求，编写测试用例（冒烟用例，接口用例，功能测试用例），用例评审会议（铁三角），目的：查漏补缺"
#
# s3 = """
#    咏鹅
# 鹅鹅鹅，
# 曲项向天歌，
# 白毛浮绿水，
# 红掌拨清波。
# """
#
# print(s1)
# print(s2)
# print(s3)

# 获取字符串中的元素
# ss = "abcdefghijklmn"

# 获取某个元素
# ss1 = ss[0]
# print(ss1)

# 获取最后一个元素
# ss2 = ss[-1]
# print(ss2)

# 获取字符串的长度
# lang = len(ss)
# print(lang)

# 字符串的切片
# 获取某段元素 ss[start:end:step]
# start 开始下标，end 结束下标但不包含，step 步长间隔
# ss3 = ss[1:4]
# print(ss3)
#
# ss4 = ss[2:8:2]
# print(ss4)
#
# # 查看变量类型
#
# a1 = 10
# a2 = '11'
# a3 = 12.6
# a4 = True
#
# print(f"a1的类型：{type(a1)}")
# print(f"a2的类型：{type(a2)}")
# print(f"a3的类型：{type(a3)}")
# print(f"a4的类型：{type(a4)}")
#
# a11 = 10
# a11 += 1
# print(a11)
#
# a11 *= 2
# print(a11)
#
# b1 = 4
# b2 = 6
# b3 = 4
# print(b1 != b2)
# print(b1 is b3)


# 元组 tuple  ()

# t = (1, "zhangsan", 21, "男", "1班", "41272220001001122", True, True, True)
#
# print(t.count(True))

# 集合 list []
# mylist1 = [1, "zhangsan", 21, "男", "1班", "41272220001001122", True, True, True]
#
# print(type(mylist1))
# print(f"前：{mylist1}")

# 列表可修改
# 增加 append

# mylist1.append("123456")
# print(f"后：{mylist1}")

# 插入 insert
# mylist1.insert(2, "郑州")
# print(f"后：{mylist1}")

# 删除 remove 以元素进行删除
# mylist1.remove(21)
# print(f"后：{mylist1}")

# pop 以下标进行删除
# mylist1.pop(3)
# print(f"后：{mylist1}")

# 修改
# mylist1[2] = "河南"
# print(f"后：{mylist1}")

# sort 排序 reverse 反转
# mylist2 = [12,65,19,38,9,43]
# mylist2.sort(reverse=True)
# print(mylist2)


# tt = [1, 2, 3, [1, 2, 3]]
# t1 = copy.copy(tt)
# t2 = copy.deepcopy(tt)
# tt[3].append(4)
#
# print(f"tt:{id(tt)}，{tt},{id(tt[3])}")
# print(f"t1:{id(t1)}，{t1},{id(t1[3])}")
# print(f"t2:{id(t2)}，{t2},{id(t2[3])}")

# 字典 {}  以键值对的形式存在
# dd = {"姓名": "lyy", "age": 19}
# print(type(dd))
# 获取值
# print(dd.get("age"))
# print(dd["age"])

# 删除
# dd.pop("age")
# print(dd)

# update
# dd2 = {"address": "河南"}
# dd.update(dd2)

# print(dd)


# set 集合 无序
# sss = {1, 6, 12, 98, "999", (1, 6, 8)}
# print(sss)

#
# tuple1 = ("lyy", 54, 30, "aaa", "张三")
# list1 = [18, "abc", "46", True]
# dict1 = {"name": "张三", "age": 18}
# set1 = {5, "36", True, "来来来"}
#
# list2 = list(tuple1)
# list3 = list(dict1)
# list4 = list(set1)
#
# tuple2 = tuple(list1)
# tuple3 = tuple(dict1)
# tuple4 = tuple(set1)
#
# set2 = set(tuple1)
# set3 = set(list1)
# set4 = set(dict1)
#
# # dict2 = dict(tuple1)
# # dict3 = dict(list1)
# # dict4 = dict(set1)
#
# print(list2)
# print(list3)
# print(list4)
# print(tuple2)
# print(tuple3)
# print(tuple4)
# print(set2)
# print(set3)
# print(set4)


mydict = {"name": "张三", "age": 18, "address": "河南", "sex": "男", "birth": "2002-10-10"}

# json  dumps 将字典转成json格式字符串
dd = json.dumps(mydict, ensure_ascii=False)
print(type(dd))
print(dd)

# loads 将字符串转成字典
cc = json.loads(dd)
print(type(cc))

